package cz.fel.cvut.rabbitmq.importer;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;

import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.MessageProperties;

public class Importer {

	 private static final String TASK_QUEUE_NAME = "task_queue";
	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		 ConnectionFactory factory = new ConnectionFactory();
		    factory.setHost(args[0]);
		    Connection connection = factory.newConnection();
		    Channel channel = connection.createChannel();

		    channel.queueDeclare(TASK_QUEUE_NAME, true, false, false, null);

		    byte[] data = FileUtils.readFileToByteArray(new File("c:/W/boot.elf"));
		    String message = "TOOOOHLE JE ZPRAAAAAAAAVAAAAAAAAAAA";

		    for (int i = 0; i < 10; i++) {
		    channel.basicPublish( "", TASK_QUEUE_NAME, 
		            MessageProperties.PERSISTENT_TEXT_PLAIN,
		            data);
		    System.out.println(" [x] Sent -> "+i);
		    }

		    channel.close();
		    connection.close();

	}

}
